<template>
    <div class="wrapper">
        <v-head></v-head>
		<v-sidebar></v-sidebar>
		<div class="content-box" :class="{'content-collapse':collapse}">
			<v-tags></v-tags>
			<div class="content">
				<transition name="move" mode="out-in">
					<keep-alive :include="tagsList">
						<router-view></router-view>
					</keep-alive>
				</transition>
				<el-backtop target=".content"></el-backtop>
			</div>
		</div>
		<el-dialog title="修改密码" :visible.sync="dialogVisible" width="30%" >
			<el-form :model="editForm" ref="editForm" :rules="rules" >
				<el-form-item label="登录账号:">
					<el-input v-model="editForm.username" placeholder="请输入姓名" size="large" readonly></el-input>
				</el-form-item>
				<el-form-item label="新密码:" prop="pwd">
					<el-input v-model="editForm.newpassword" placeholder="请输入新密码" size="large"></el-input>
				</el-form-item>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="dialogVisible = false">取 消</el-button>
				<el-button type="primary" >确 定</el-button>
			</span>
		</el-dialog>
    </div>
</template>

<script>
import vHead from './Header.vue';
import vSidebar from './Sidebar.vue';
import vTags from './Tags.vue';
import bus from './bus';
import Permission from '../../views/403.vue'
export default {
    data() {
        return {
            tagsList: [],
            collapse: false,
			pageType:-1,
			isEditPwd:0,
			type:'',
			onClick:0,
			dialogVisible:false,
			mobile:window.sessionStorage.getItem('username') + '(不可编辑)',
			editForm:{},
			rules:{
				newpassword: [{ required: true, message: '请输入新密码', trigger: 'blur' }],
			},
        };
    },
    components: {
        vHead,
        vSidebar,
        vTags,
		Permission
    },
    created() {
        bus.$on('collapse-content', msg => {
            this.collapse = msg;
        });
		bus.$on('onClick', msg => {
		   this.onClick = msg
		});
		bus.$on('isEditPwd', msg => {
			if(msg == 1){
				this.dialogVisible = true
			}
		});
        // 只有在标签页列表里的页面才使用keep-alive，即关闭标签之后就不保存到内存中了。
        bus.$on('tags', msg => {
            let arr = [];
            for (let i = 0, len = msg.length; i < len; i++) {
                msg[i].name && arr.push(msg[i].name);
            }
            this.tagsList = arr;
        });
    },
	mounted() {
		if(sessionStorage.getItem('onClick')){
			this.onClick = sessionStorage.getItem('onClick')
		}
		this.type = sessionStorage.getItem('userType')
	},
	methods:{
		
	}
};
</script>
